﻿Imports System.Collections.Generic

Imports System.Xml.Linq

Imports Microsoft.VisualStudio.TestTools.UnitTesting

Imports NETWeather.NOAA



'''<summary>
'''This is a test class for NOAATest and is intended
'''to contain all NOAATest Unit Tests
'''</summary>
<TestClass()> _
Public Class NOAATest


    Private testContextInstance As TestContext

    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(value As TestContext)
            testContextInstance = Value
        End Set
    End Property

#Region "Additional test attributes"
    '
    'You can use the following additional attributes as you write your tests:
    '
    'Use ClassInitialize to run code before running the first test in the class
    '<ClassInitialize()>  _
    'Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
    'End Sub
    '
    'Use ClassCleanup to run code after all tests in a class have run
    '<ClassCleanup()>  _
    'Public Shared Sub MyClassCleanup()
    'End Sub
    '
    'Use TestInitialize to run code before running each test
    '<TestInitialize()>  _
    'Public Sub MyTestInitialize()
    'End Sub
    '
    'Use TestCleanup to run code after each test has run
    '<TestCleanup()>  _
    'Public Sub MyTestCleanup()
    'End Sub
    '
#End Region


    '''<summary>
    '''A test for GetWeather in US Standard units
    '''</summary>
    <TestMethod()> _
    Public Sub GetWeatherTestUSStandard()

        ' Setup the test
        Dim target As NOAA = New NOAA()
        Dim zipCode As String = "46514"
        Dim units As NOAA.Units = NOAA.Units.USStandard
        Dim actual As List(Of WeatherByDayResults)
        actual = target.GetWeather(zipCode, units)

        ' if the result is not null, the method has succeeded.
        Assert.IsNotNull(actual)


        ' print out the results of the method.
        Debug.WriteLine("Weather Results Temp=Fahrenheit")
        Debug.Indent()
        For Each a In actual
            Debug.WriteLine("Max:" & vbTab & a.MaxTemperature)
            Debug.WriteLine("Min:" & vbTab & a.MinTemperature)
            Debug.WriteLine("Image:" & vbTab & a.Image.ToString)
            Debug.WriteLine("StartTime:" & vbTab & a.StartTime.ToString)
            Debug.WriteLine("EndTime:" & vbTab & a.EndTime.ToString)
            Debug.WriteLine("")
        Next
        Debug.Unindent()
    End Sub


    ''' <summary>
    ''' A test for GetWeather in Metric units
    ''' </summary>
    ''' <remarks></remarks>
    <TestMethod()> _
    Public Sub GetWeatherTestMetric()

        ' Setup the test
        Dim target As NOAA = New NOAA()
        Dim zipCode As String = "46514"
        Dim units As NOAA.Units = NOAA.Units.Metric
        Dim actual As List(Of WeatherByDayResults)
        actual = target.GetWeather(zipCode, units)

        ' if the result is not null, the method has succeeded.
        Assert.IsNotNull(actual)

        ' print out the results of the method.
        Debug.WriteLine("Weather Results: Temp=Celsius")
        Debug.Indent()
        For Each a In actual
            Debug.WriteLine("Max:" & vbTab & a.MaxTemperature)
            Debug.WriteLine("Min:" & vbTab & a.MinTemperature)
            Debug.WriteLine("Image:" & vbTab & a.Image.ToString)
            Debug.WriteLine("StartTime:" & vbTab & a.StartTime.ToString)
            Debug.WriteLine("EndTime:" & vbTab & a.EndTime.ToString)
            Debug.WriteLine("")
        Next
        Debug.Unindent()

    End Sub
End Class
